<template>
    <div></div>
</template>

<script>
export default {
    mounted() {
        console.log(this.$route.query)
        let n = this.$route.query.n
        if (!n) {
            this.openMessage('warning', '参数无效')
            return
        }
        this.toDoA(n);
    },
    methods: {
        toDoA(n) { // 再做一个
			let teamNum = localStorage['teamNum'];
			var formData = new FormData();
			formData.append('DocumentNumber', n);
			formData.append('TeamNum', teamNum);
			formData.append('IsMaster', 0);
			formData.append('IsVisiable', 1);
			this.$axios.post('/CopyDocument', formData)
			.then(({data}) => {
				try {
					data = JSON.parse(data);
				} catch (error) {
					data = ''
				}
				if (data) {
					console.log(data)
					let url = "/designer/" + window.btoa("DocumentNumber=" + data.DocumentNumber)
					this.$router.replace(url)
				} else {
					this.openMessage('warning', '复制的模板飞走了')
				}
			})
			.catch(err=> {
				this.openMessage('warning', '复制的模板飞走了')
			})
        },
        openMessage(type = '', message, duration, showClose) {
            this.$message.closeAll();
            this.$message({ type, message, center: true, customClass: 'aly-message', center: true, duration, showClose });
        }
    }
}
</script>

<style>

</style>
